package com.shelpe.services.simbasync.service.simbaproxy;

import java.util.List;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;

@FeignClient(name="${simbaproxy.serviceID}", url="${simbaproxy.url}")
@RequestMapping(value = "/simba")
public interface OrderProxy {
	
	/*
	 * 
	 *订单查询
	 * 
	 * */
	@RequestMapping(method = RequestMethod.GET, value = "/taobao.vas.order.search")
	public OrderResponse getOrder(@RequestHeader("tenantID") long userId, @RequestParam("article_code") String articleCode,
			@RequestParam("start_created") String startTime, @RequestParam("end_created") String endTime, 
			@RequestParam("page_no") int pageNo, @RequestParam("page_size") int pageSize);
	
	/**
	 * 订购关系查询
	 * 
	 * */
	@RequestMapping(method = RequestMethod.GET, value = "/taobao.vas.subscribe.get")
	public String getSubscribeRelation(@RequestParam("nick") String nick, @RequestParam("article_code") String articleCode);
	
	@Data
	public static class OrderResponse extends SimbaProxyBaseDto{
		
		@JsonProperty("vas_order_search_response")
		private ArticleOrders orderRes;
	}
	
	@Data
	public static class ArticleOrders {
		
		@JsonProperty("article_biz_orders")
		private BizOrder bizOrder;
		@JsonProperty("total_item")
		private Integer totalItem;
	}
	
	@Data
	public static class BizOrder {
		
		@JsonProperty("article_biz_order")
		private List<PurchaseOrderDto> orderDto;
	}
	
	@Data
	public static class PurchaseOrderDto {
		@JsonProperty("article_code")
		private String articleCode;
		@JsonProperty("article_name")
		private String articleName;
		@JsonProperty("item_code")
		private String itemCode;
		@JsonProperty("article_item_name")
		private String itemName;
		@JsonProperty("biz_type")
		private Integer bizType;
		@JsonProperty("order_cycle_end")
		private String orderCycleEnd;
		private String fee;
		private String create;
		@JsonProperty("order_id")
		private Long orderId;
		private String nick;
		@JsonProperty("order_cycle")
		private String orderCycle;
		@JsonProperty("biz_order_id")
		private Long bizOrderId;
		@JsonProperty("prom_fee")
		private String promFee;
		@JsonProperty("refund_fee")
		private String refundFee;
		@JsonProperty("order_cycle_start")
		private String orderCycleStart;
		@JsonProperty("total_pay_fee")
		private String totalPayFee;
	}
	
}
